<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
Movie[] movieList;
%>
<%
PersonBussinessProxy personBI = new PersonBussinessProxy();
personBI.setEndpoint(ServiceEndPoints.PersonEndPoint);
Long membershipId = Long.parseLong(session.getAttribute("MembershipId").toString());
Movie[] moviesList = personBI.customerqueue(membershipId);
session.setAttribute("cartMovies", moviesList);
movieList=(Movie[])session.getAttribute("cartMovies");

%>
<%@page import="com.beans.Movie" %>
<%@page import="com.bussiness.PersonBussinessProxy" %>
<%@page import="com.constants.ServiceEndPoints" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Online Video Library</title>
</head>
<script type="text/javascript">
function validateCart(){
	
var i;
var flag = false;
var eleLength = document.deletecheckout.elements.length;

	for (i=0;i<eleLength;i++){
		 var type = deletecheckout.elements[i].type;
		if (type=="checkbox" && deletecheckout.elements[i].checked){
		flag = true;
		break;
		}
	}
	if(flag == false)
		{
		
		document.all("error").innerHTML  = "Please select atleast one Item to Rent/Delete";
		return false;
		}
	else{
		
		return true;
	}
}
</script>
<body>
<form id="deletecheckout" name="deletecheckout" method="POST" action="DeleteCheckoutServlet" onsubmit="return validateCart();">
	<div align="justify">
	</div>
	
	<br>
	<br>
	<div style="text-align:center;font-size:1em;font-family: sans serif;">
	<% String status = (String)request.getAttribute("ServerException");
			if(status != null){
			%>
			
			<label style="size: 25; color: green"><%=status%></label>	<%} %>	
			<% String status1 = (String)request.getAttribute("ServerMessage");
			if(status1 != null){
			%>
			<label style="size: 25; color: green"><%=status1%></label>	<%} %>	
			<label id ="error" style="size: 25; color: green"></label>
			</div>
	<div class ="inputColumn" id = "CartItems"  
				style="text-align: left; border: none; margin: auto;">	
				<div style="text-align:center;color:black;font-size:2em;font-family: sans serif;">
				<font size="4">Movies in your cart</font></div>
				
			<table align="center" border="1" style="border-style: dashed; background-color: rgb(254,252,180);">
			<%
			if(movieList != null)
			{
			%>
			
				<tr>
				<th align="center" style="color:red" bordercolor="red">No</th>
				<th align="center" style="color:red" bordercolor="red">Movie Name </th>
				<th align="center" style="color:red" bordercolor="red">Category</th>
				<th align="center" style="color:red" bordercolor="red">Rating</th>
				</tr>
				<% 
				
				for(int i=0;i<movieList.length;i++)
				{
				%>
				<tr bordercolor="black" >
				<td bordercolor="black">
					 	<input type="checkbox" value ='<%=movieList[i].getMovieId()%>' name="movieid"> 
					</td>
				  <td>
					 	<label id ="MovieName" style="size: 25;"><%=movieList[i].getMovieName()%></label> 
					</td>
					<td>
						<label id="MovieCategory" style="size: 35;"><%=movieList[i].getCategoryname()%></label>
					</td>
					<td>
						<label id="MovieRating" style="size: 35;"><%=movieList[i].getRating()%></label>
					</td>
				</tr>
				<%
				}
				%>
			</table>
			<div style="text-align:center;color:red;font-size:2em;font-family: sans serif;">
			<input type="submit" value="Delete" name="submit" align ="middle"/>
			<input type="submit" value="Check Out" name="submit" align ="middle"/>
			</div>
				<%			
			}
			else
			{
			%>
			<font size="4">No Movies In Cart</font>
			<%
			}
			%>
	</div>
</form>
</body>
</html>